import { ApiProperty } from '@nestjs/swagger';
import { IsEmail, IsEnum, IsInt, IsOptional, IsString } from 'class-validator';
import { Transform } from 'class-transformer';

export class FindUserDto {
  @ApiProperty({ description: '页码', default: 1 })
  @IsInt()
  @IsOptional()
  @Transform(({ value }) => parseInt(value))
  pageNum?: number = 1;

  @ApiProperty({ description: '每页记录数', default: 10 })
  @IsInt()
  @IsOptional()
  @Transform(({ value }) => parseInt(value))
  pageSize?: number = 10;

  @ApiProperty({ description: '用户ID', required: false })
  @IsInt()
  @IsOptional()
  @Transform(({ value }) => value ? parseInt(value) : undefined)
  id?: number;

  @ApiProperty({ description: '用户名', required: false })
  @IsString()
  @IsOptional()
  username?: string;

  @ApiProperty({ description: '邮箱', required: false })
  @IsOptional()
  email?: string;

  @ApiProperty({ description: '性别(0-未知,1-男,2-女)', required: false, enum: [0, 1, 2] })
  @IsEnum([0, 1, 2])
  @IsOptional()
  @Transform(({ value }) => value !== undefined ? parseInt(value) : undefined)
  gender?: number;

  @ApiProperty({ description: '状态(0-正常,1-已删除)', required: false, enum: [0, 1] })
  @IsEnum([0, 1])
  @IsOptional()
  @Transform(({ value }) => value !== undefined ? parseInt(value) : undefined)
  is_delete?: number;
}